
var TabInitShow = {
    soulSort: false,
    limit: 999999999,
    method: "POST",
    defaultToolbar: ['','filter', 'print', 'exports'],
    overflow: {
        type: 'tips'
        ,hoverTime: 500
        ,color: '#fff'
        ,bgColor: '#393d49'
    },
    request: {pageName: 'page',limitName: 'pagesize'},
    response: {statusCode: 2000},
    filter: {
        items:['column','data','condition','editCondition','excel','clearCache'],
        cache: true,
        clearFilter: true
    },
    text: {
        none: '<div><span>无数据</span></div>'
    }
};
function get_table_contextmenu(soulTable){
    return {
        header: [{
            name: '复制',
            icon: 'layui-icon layui-icon-template',
            click: function(obj) {
                soulTable.copy(obj.text)
                layer.msg('复制成功！')

            }
        }],
        body: [{name: '复制',icon: 'layui-icon layui-icon-template', click: function(obj) {
                soulTable.copy(obj.text)
                layer.msg('复制成功！')
            }
        }],
    }
}


$(document).ready(function () {
    // 明细点击隐藏事件
    $('#showPage .title-list').click(function () {
        if($(this).next().is(':hidden')){
            $(this).next().show();
            $(this).find('.title-icon').html('<i class="layui-icon layui-icon-down"></i>');
        }else{
            $(this).next().hide();
            $(this).find('.title-icon').html('<i class="layui-icon layui-icon-up"></i>');
        }
    });
});

/**
 * 详情 - 明细暂无数据
 * @returns
 */
function file_none(cols) {
    var str = '';
    str += '<td colspan="'+cols+'" class="filetd">';
    str += '<div><div><img class="filetd_img" src="/static/admin/images/welnodata.png" /></div><span>暂无数据</span></div>';
    str += '</td>';
    return str;
}


/**
 * 详情 - 明细赋值
 * @param ele
 * @param str
 */
function file_assign(ele, str) {
    let imgstr = 'welnodata.png';
    if(str.indexOf(imgstr) >= 0){
        // $(ele).html(str);
        $(ele).parent('table').html(str);
    }else{
        $(ele).html(str);
    }
}



/**
 * 数字转中文
 * @param dValue
 * @returns
 */
function chineseNumber(dValue, unit) {
    if(unit == undefined || unit == false){
        unit = '元';
    }
    var maxDec = 2;
    // 验证输入金额数值或数值字符串：
    dValue = dValue.toString().replace(/,/g, "");
    dValue = dValue.replace(/^0+/, ""); // 金额数值转字符、移除逗号、移除前导零
    if (dValue == "") {
        return "零"+unit+"整";
    } // （错误：金额为空！）
    else if (isNaN(dValue)) {
        return "错误：金额不是合法的数值！";
    }
    var minus = ""; // 负数的符号“-”的大写：“负”字。可自定义字符，如“（负）”。
    var CN_SYMBOL = ""; // 币种名称（如“人民币”，默认空）
    if (dValue.length > 1) {
        if (dValue.indexOf('-') == 0) {
            dValue = dValue.replace("-", "");
            minus = "负";
        } // 处理负数符号“-”
        if (dValue.indexOf('+') == 0) {
            dValue = dValue.replace("+", "");
        } // 处理前导正数符号“+”（无实际意义）
    }
    // 变量定义：
    var vInt = "";
    var vDec = ""; // 字符串：金额的整数部分、小数部分
    var resAIW; // 字符串：要输出的结果
    var parts; // 数组（整数部分.小数部分），length=1时则仅为整数。
    var digits, radices, bigRadices, decimals; // 数组：数字（0~9——零~玖）；基（十进制记数系统中每个数字位的基是10——拾,佰,仟）；大基（万,亿,兆,京,垓,杼,穰,沟,涧,正）；辅币（元以下，角/分/厘/毫/丝）。
    var zeroCount; // 零计数
    var i, p, d; // 循环因子；前一位数字；当前位数字。
    var quotient, modulus; // 整数部分计算用：商数、模数。
    // 金额数值转换为字符，分割整数部分和小数部分：整数、小数分开来搞（小数部分有可能四舍五入后对整数部分有进位）。
    var NoneDecLen = (typeof (maxDec) == "undefined" || maxDec == null || Number(maxDec) < 0 || Number(maxDec) > 5); // 是否未指定有效小数位（true/false）
    parts = dValue.split('.'); // 数组赋值：（整数部分.小数部分），Array的length=1则仅为整数。
    if (parts.length > 1) {
        vInt = parts[0];
        vDec = parts[1]; // 变量赋值：金额的整数部分、小数部分
        if (NoneDecLen) {
            maxDec = vDec.length > 5 ? 5 : vDec.length;
        } // 未指定有效小数位参数值时，自动取实际小数位长但不超5。
        var rDec = Number("0." + vDec);
        rDec *= Math.pow(10, maxDec);
        rDec = Math.round(Math.abs(rDec));
        rDec /= Math.pow(10, maxDec); // 小数四舍五入
        var aIntDec = rDec.toString().split('.');
        if (Number(aIntDec[0]) == 1) {
            vInt = (Number(vInt) + 1).toString();
        } // 小数部分四舍五入后有可能向整数部分的个位进位（值1）
        if (aIntDec.length > 1) {
            vDec = aIntDec[1];
        } else {
            vDec = "";
        }
    } else {
        vInt = dValue;
        vDec = "";
        if (NoneDecLen) {
            maxDec = 0;
        }
    }
    if (vInt.length > 44) {
        return "错误：金额值太大了！整数位长【" + vInt.length.toString() + "】超过了上限——44位/千正/10^43（注：1正=1万涧=1亿亿亿亿亿，10^40）！";
    }
    // 准备各字符数组 Prepare the characters corresponding to the digits:
    digits = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); // 零~玖
    radices = new Array("", "拾", "佰", "仟"); // 拾,佰,仟
    bigRadices = new Array("", "万", "亿", "兆", "京", "垓", "杼", "穰", "沟", "涧", "正"); // 万,亿,兆,京,垓,杼,穰,沟,涧,正
    decimals = new Array("角", "分", "厘", "毫", "丝"); // 角/分/厘/毫/丝
    resAIW = ""; // 开始处理
    // 处理整数部分（如果有）
    if (Number(vInt) > 0) {
        zeroCount = 0;
        for (i = 0; i < vInt.length; i++) {
            p = vInt.length - i - 1;
            d = vInt.substr(i, 1);
            quotient = p / 4;
            modulus = p % 4;
            if (d == "0") {
                zeroCount++;
            } else {
                if (zeroCount > 0) {
                    resAIW += digits[0];
                }
                zeroCount = 0;
                resAIW += digits[Number(d)] + radices[modulus];
            }
            if (modulus == 0 && zeroCount < 4) {
                resAIW += bigRadices[quotient];
            }
        }
        resAIW += unit;
    }
    // 处理小数部分（如果有）
    for (i = 0; i < vDec.length; i++) {
        d = vDec.substr(i, 1);
        if (d != "0") {
            resAIW += digits[Number(d)] + decimals[i];
        }
    }
    // 处理结果
    if (resAIW == "") {
        resAIW = "零" + unit;
    } // 零元
    if (vDec == "") {
        resAIW += "";
    } // ...元整
    resAIW = CN_SYMBOL + minus + resAIW; // 人民币/负......元角分/整
    return resAIW;
}



function public_flow_show_display22(data) {
    if(!data.bill){
        showpage_dropopt();
        return false;
    }

    // 顶部信息
    $("#flow_show_tit .fshow_modenum").text(data.bill.modename);
    $("#flow_show_tit .fshow_flowtext").html(data.bill.flowtext);
    // $("#flow_show_tit .fshow_sericnum").text(data.bill.sericnum);
    $("#flow_show_tit").removeClass('layui-hide');
    if(data.bill.isturn > 0){
        $("#flow_show_tit .flow-status-img img").attr('src', '../../static/admin/images/flowstatus/'+data.bill.status+'.png');
    }


    //流程线
    if(data.bill.isturn > 0 && data.line && data.line.length > 0){
        $('#flow_show_info #flowLine').removeClass('layui-hide');
        $('#flow_show_info #flowLine').html(get_flow_line(data.line));
    }


    //流程信息
    $("#flow_show_info .fshow_sericnum2").text(data.bill.sericnum);
    $("#flow_show_info .fshow_created_at").text(data.bill.created_at);
    $("#flow_show_info .fshow_flowuser").text(data.bill.flowuser);
    $("#flow_show_info .fshow_flowdept").text(data.bill.flowdept);
    $("#flow_show_info .fshow_summary").text(data.bill.summary);
    $("#flow_show_info").removeClass('layui-hide');

    //按钮
    if(data.bill.but_edit){
        $("#flow_but_edit").removeClass('layui-hide').click(function () {
            var billyushen = data.bill.but_edit_yushen;
            openParentPageEdit('../'+data.bill.modenum+'/flow_edit.php?close=1&billyushen='+billyushen+'&isturn=1&id='+data.bill.mid)
            layer_close();
        });
    }
    if(data.bill.but_agree){
        $("#flow_but_agree").removeClass('layui-hide').click(function () {
            openPage('../public_flow/flow_opt_agree.php?id='+data.bill.id+'&isqian='+data.isqian, '770px', '490px')
        });
    }
    // if(data.bill.but_agreeno){
    //     $("#flow_but_agreeno").removeClass('layui-hide').click(function () {
    //         openPage('../public_flow/flow_opt_agreeno.php?id='+data.bill.id, '770px', '490px')
    //     });
    // }
    if(data.bill.but_tui){
        $("#flow_but_tui").removeClass('layui-hide').click(function () {
            openPage('../public_flow/flow_opt_tui.php?id='+data.bill.id+'&isqian='+data.isqian, '770px', '490px')
        });
    }

    var dropData = [];
    if(data.bill.but_agreeno){
        dropData.push({title: '不同意',id: 2});
    }
    if(data.bill.but_add){
        dropData.push({title: '加签',id: 4});
    }
    if(data.bill.but_zhuan){
        dropData.push({title: '转签',id: 5});
    }
    if(data.bill.but_out){
        dropData.push({title: '退出审核',id: 6});
    }
    if(data.bill.isturn == 1){
        if(data.bill.status == 0 || data.bill.status == 1 || data.bill.status == 2){
            dropData.push({title: '分享',id: 70});
            dropData.push({title: '评论',id: 80});
        }
    }
    dropData.push({title: '导出',id: 100});
    dropData.push({title: '打印',id: 101});

    layui.use(['dropdown'], function() {
        var dropdown = layui.dropdown;
        dropdown.render({
            elem: '.opt'
            ,data: dropData
            ,click: function(obj){
                if(obj.id == 2){
                    openPage('../public_flow/flow_opt_agreeno.php?id='+data.bill.id+'&isqian='+data.isqian, '770px', '490px');
                }else if(obj.id == 4){
                    openPage('../public_flow/flow_opt_add.php?id='+data.bill.id+'&isqian='+data.isqian, '770px', '490px');
                }else if(obj.id == 5){
                    openPage('../public_flow/flow_opt_zhuan.php?id='+data.bill.id+'&isqian='+data.isqian, '770px', '490px');
                }else if(obj.id == 6){
                    openPage('../public_flow/flow_opt_out.php?id='+data.bill.id, '770px', '490px');
                }else if(obj.id == 70){
                    openPage('../public_flow/flow_opt_share.php?id='+data.bill.id, '770px', '490px');
                }else if(obj.id == 80){
                    openPage('../public_flow/flow_opt_talk.php?id='+data.bill.id, '770px', '490px');
                }else if(obj.id == 100){
                    export_word()
                }else if(obj.id == 101){
                    print_area()
                }
            }
        });
    });

    //流程记录
    var shenlog_str = '';
    let shenlog = data.shenlog;
    for (let i=0; i<shenlog.length; i++){
        let _num = parseInt(i + 1);
        shenlog_str += '<tr>';
        shenlog_str += '<td style="min-width: 10px">'+_num+'</td>';
        shenlog_str += '<td>'+shenlog[i].name+'</td>';
        shenlog_str += '<td>'+shenlog[i].chuname+'</td>';
        shenlog_str += '<td>'+shenlog[i].explain+'</td>';
        if(shenlog[i].qian_id > 0){
            shenlog_str += '<td><img src="'+get_file_complete(shenlog[i].qian)+'" data_src="'+get_file_complete(shenlog[i].qian)+'"></td>';
        }else{
            shenlog_str += '<td></td>';
        }
        shenlog_str += '<td>'+shenlog[i].created_user+'</td>';
        shenlog_str += '<td>'+shenlog[i].created_at+'</td>';
        shenlog_str += '<td>'+shenlog[i].promer_name+'</td>';
        shenlog_str += '<td>';
        for (var key in shenlog[i].filesarr) {
            var fileext = shenlog[i].filesarr[key].ext;
            var encpath = shenlog[i].filesarr[key].encpath;
            var filename = shenlog[i].filesarr[key].name;
            shenlog_str += '<div style="position: relative;margin: 3px 10px;cursor: pointer;">';

            if(fileext == 'png' || fileext == 'pneg' || fileext == 'jpg' || fileext == 'jpeg' || fileext == 'gif'){
                shenlog_str += ' <div style="display: none"><img src="'+get_file_complete(encpath)+'" data_src="'+get_file_complete(encpath)+'"></div>';
                shenlog_str += '<div class="show_viewer_img"  style="color:#0079FE">'+filename+'</div>';
            }else if(fileext == 'pdf'){
                shenlog_str += '<div onclick="upload_files_viewer_pdf_show(\''+get_file_complete(encpath)+'\')"  style="color:#0079FE">'+filename+'</div>';
            }else if(fileext == 'doc' || fileext == 'docx' || fileext == 'xls' || fileext == 'xlsx' || fileext == 'ppt' || fileext == 'pptx'){
                shenlog_str += '<div onclick="upload_files_vieweroffice_show(\''+get_file_complete(encpath)+'\')"  style="color:#0079FE">'+filename+'</div>';
            }else{
                shenlog_str += '<div onclick="upload_files_show_yulan_not()">'+filename+'</div>';
            }
            shenlog_str += '<div onclick="public_down_file(\''+shenlog[i].filesarr[key].encpath+'\')" style="position: absolute;right: 0;top: 0;color:#0079FE"><i class="layui-icon layui-icon-download-circle"></i></div>';
            shenlog_str += '</div>';
        }
        shenlog_str += '</td>';
        shenlog_str += '</tr>';
    }

    if(shenlog_str == ''){
        shenlog_str += file_none(6);
    }
    file_assign('#shenlogDiv #shenlog-tbody', shenlog_str);

    // $('#shenlogDiv #shenlog-tbody').html(shenlog_str);
    $('#shenlogDiv').removeClass('layui-hide');
    var flowshenLogViewerObj = new Viewer(document.getElementById('shenlogDiv'));
    $('#shenlogDiv #shenlog-tbody .show_viewer_img').click(function () {
        flowshenLogViewerObj.show();
    });



    //评论记录
    var talk_str = '';
    let talk = data.talk;
    for (let i=0; i<talk.length; i++){
        let _num = parseInt(i + 1);
        talk_str += '<tr>';
        talk_str += '<td style="min-width: 10px">'+_num+'</td>';
        talk_str += '<td>'+talk[i].uid_name+'</td>';
        talk_str += '<td>'+talk[i].domer_name+'</td>';
        talk_str += '<td>'+talk[i].explain+'</td>';
        talk_str += '<td>'+talk[i].created_at+'</td>';
        talk_str += '<td>';
        for (var key in talk[i].filesarr) {
            var fileext = talk[i].filesarr[key].ext;
            var encpath = talk[i].filesarr[key].encpath;
            var filename = talk[i].filesarr[key].name;
            talk_str += '<div style="position: relative;margin: 3px 10px;cursor: pointer;">';

            if(fileext == 'png' || fileext == 'pneg' || fileext == 'jpg' || fileext == 'jpeg' || fileext == 'gif'){
                talk_str += ' <div style="display: none"><img src="'+get_file_complete(encpath)+'" data_src="'+get_file_complete(encpath)+'"></div>';
                talk_str += '<div class="show_viewer_img"  style="color:#0079FE">'+filename+'</div>';
            }else if(fileext == 'pdf'){
                talk_str += '<div onclick="upload_files_viewer_pdf_show(\''+get_file_complete(encpath)+'\')"  style="color:#0079FE">'+filename+'</div>';
            }else if(fileext == 'doc' || fileext == 'docx' || fileext == 'xls' || fileext == 'xlsx' || fileext == 'ppt' || fileext == 'pptx'){
                talk_str += '<div onclick="upload_files_vieweroffice_show(\''+get_file_complete(encpath)+'\')"  style="color:#0079FE">'+filename+'</div>';
            }else{
                talk_str += '<div onclick="upload_files_show_yulan_not()">'+filename+'</div>';
            }
            talk_str += '<div onclick="public_down_file(\''+talk[i].filesarr[key].encpath+'\')" style="position: absolute;right: 0;top: 0;color:#0079FE"><i class="layui-icon layui-icon-download-circle"></i></div>';
            talk_str += '</div>';
        }
        talk_str += '</td>';
        talk_str += '</tr>';
    }

    if(talk_str == ''){
        talk_str += file_none(6);
    }
    file_assign('#talkDiv #talk-tbody', talk_str);

    // $('#talkDiv #talk-tbody').html(talk_str);
    $('#talkDiv').removeClass('layui-hide');
    var flowTalkViewerObj = new Viewer(document.getElementById('talkDiv'));
    $('#talkDiv #talk-tbody .show_viewer_img').click(function () {
        flowTalkViewerObj.show();
    });



    //关联流程
    var flowrelas_str = '';
    let flowrelas = data.flowrelas_info;
    for (let i=0; i<flowrelas.length; i++){
        let _num = parseInt(i + 1);
        flowrelas_str += '<tr>';
        flowrelas_str += '<td style="min-width: 10px">'+_num+'</td>';
        flowrelas_str += '<td>'+flowrelas[i].modename+'</td>';
        flowrelas_str += '<td><span class="colorlan" onclick="openPage(\'../'+flowrelas[i].modenum+'/show.php?id='+flowrelas[i].mid+'\')">'+flowrelas[i].sericnum+'</span></td>';
        flowrelas_str += '</tr>';
    }

    if(flowrelas_str == ''){
        flowrelas_str += file_none(3);
    }
    file_assign('#flowrelasDiv #flowrelas-tbody', flowrelas_str);

    // $('#flowrelasDiv #flowrelas-tbody').html(flowrelas_str);
    $('#flowrelasDiv').removeClass('layui-hide');
}
function public_flow_show_display(data) {
    if(!data.bill){
        showpage_dropopt();
        return false;
    }

    $(".pageshowtitle").text(data.bill.modename+'详情');

    //流程信息
    $("#flow_show_info .fshow_modename").text(data.bill.modename);
    $("#flow_show_info2 .fshow_modename").text(data.bill.modename);
    $("#flow_show_info .fshow_sericnum2").text(data.bill.sericnum);
    $("#flow_show_info2 .fshow_sericnum2").text(data.bill.sericnum);
    $("#flow_show_info .fshow_flowuser").text(data.bill.flowuser);
    $("#flow_show_info2 .fshow_flowuser").text(data.bill.flowuser);
    $("#flow_show_info .fshow_flowdept").text(data.bill.flowdept);
    $("#flow_show_info2 .fshow_flowdept").text(data.bill.flowdept);
    $("#flow_show_info .fshow_created_at").text(data.bill.created_at);
    $("#flow_show_info2 .fshow_created_at").text(data.bill.created_at);
    $("#flow_show_info .fshow_summary").text(data.bill.summary);
    $("#flow_show_info2 .fshow_summary").text(data.bill.summary);
    $("#flow_show_info").removeClass('layui-hide');


    if(data.bill.deleted_user == 0){
        if(data.bill.isturn == 1){
            if(data.bill.status == 0){
                $("#flow_show_info .fshow_flowstatus").html('<span class="fbstatus0">审批中</span>');
                $("#flow_show_info2 .fshow_flowstatus").html('<span class="fbstatus0">审批中</span>');
            }else if(data.bill.status == 1){
                $("#flow_show_info .fshow_flowstatus").html('<span class="fbstatus1">审核通过</span>');
                $("#flow_show_info2 .fshow_flowstatus").html('<span class="fbstatus1">审核通过</span>');
            }else if(data.bill.status == 2){
                $("#flow_show_info .fshow_flowstatus").html('<span class="fbstatus2">审核不通过</span>');
                $("#flow_show_info2 .fshow_flowstatus").html('<span class="fbstatus2">审核不通过</span>');
            }else if(data.bill.status == 3){
                $("#flow_show_info .fshow_flowstatus").html('<span class="fbstatus3">超管结束</span>');
                $("#flow_show_info2 .fshow_flowstatus").html('<span class="fbstatus3">超管结束</span>');
            }else if(data.bill.status == 5){
                $("#flow_show_info .fshow_flowstatus").html('<span class="fbstatus5">流程作废</span>');
                $("#flow_show_info2 .fshow_flowstatus").html('<span class="fbstatus5">流程作废</span>');
            }
        }else{
            $("#flow_show_info .fshow_flowstatus").html('<span class="fbstatusturn">待提交</span>');
            $("#flow_show_info2 .fshow_flowstatus").html('<span class="fbstatusturn">待提交</span>');
        }
    }
    if(data.bill.status == 0 && data.bill.isturn == 1 && data.bill.deleted_user == 0){
        $("#flow_show_info .fshow_curshentds .fshow_curshenname").html(data.bill.flowtext);
        $("#flow_show_info2 .fshow_curshentds .fshow_curshenname").html(data.bill.flowtext);
        $("#flow_show_info .fshow_curshentds").removeClass('layui-hide');
        $("#flow_show_info2 .fshow_curshentds").removeClass('layui-hide');
    }

    //审批流程信息
    var lineList = data.line;
    var lineStr = '';
    for(var i=0;i<lineList.length;i++){

        if(lineList[i].state == 2){
            lineStr += '<span class="colorlv">';
            lineStr += '<span><i class="layui-icon layui-icon-ok-circle"></i></span>';
            lineStr += '<span>'+lineList[i].name+'</span>';
            lineStr += '</span>';
        }
        if(lineList[i].state == 1){
            lineStr += '<span class="colorcheng">';
            lineStr += '<span><i class="layui-icon layui-icon-time"></i></span>';
            lineStr += '<span><b>'+lineList[i].name+'</b></span>';
            lineStr += '</span>';
        }
        if(lineList[i].state == 0){
            lineStr += '<span class="colorhui">';
            lineStr += '<span><i class="layui-icon layui-icon-time"></i></span>';
            lineStr += '<span>'+lineList[i].name+'</span>';
            lineStr += '</span>';
        }

        if(i < lineList.length-1){
            lineStr += ' → ';
        }
    }

    $("#flow_show_info .fshow_linedata").html(lineStr);
    $("#flow_show_info2 .fshow_linedata").html(lineStr);


    //关联流程
    if(data.flowrelas_info.length > 0){
        var flowrelas_str = '';
        let flowrelas = data.flowrelas_info;
        for (let i=0; i<flowrelas.length; i++){
            if(flowrelas_str){
                flowrelas_str += '<span class="colorlan" onclick="openPage(\'../'+flowrelas[i].modenum+'/show.php?id='+flowrelas[i].mid+'\')">';
                flowrelas_str += '，'+flowrelas[i].modename+'('+flowrelas[i].sericnum+')';
                flowrelas_str += '</span>';
            }else{
                flowrelas_str += '<span class="colorlan" onclick="openPage(\'../'+flowrelas[i].modenum+'/show.php?id='+flowrelas[i].mid+'\')">';
                flowrelas_str += flowrelas[i].modename+'('+flowrelas[i].sericnum+')';
                flowrelas_str += '</span>';
            }
        }
        $('#flowrelasDiv').removeClass('layui-hide');
        $('#flowrelasDiv #flowrelasInfo').html(flowrelas_str);
    }



    layui.use(['form', 'layer', "laytp",'element','dropdown','laypage','table','soulTable'], function() {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable,element = layui.element;

        if(data.shenlog.length > 0){
            $('#shenlogDiv').removeClass('layui-hide');
            table.render({
                elem: "#datalist_shenlog",data:data.shenlog, toolbar: '#toolbarDemo_shenlog', page: false
                ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                , cols: [[
                    {type:'numbers',title:'序号',fixed:'left'}
                    ,{field: 'name', title: '步骤名称'}
                    ,{field: 'chuname', title: '处理操作'}
                    ,{field: 'explain', title: '处理意见'}
                    ,{field:'',title:'签名',templet: function(d){
                        if(d.qian_id > 0){
                            return '<img src="'+get_file_complete(d.qian)+'" style="height: 35px">'
                        }
                        return '';
                    }}
                    ,{field: 'created_user', title: '处理人'}
                    ,{field: 'created_at', title: '处理时间'}
                    ,{field: 'promer_name', title: '抄送给'}
                    ,{field:'',title:'附件',templet: function(d){
                        if(d.filesarr.length > 0){

                            return '<span class="colorlan" onclick="openTabFilePage(\'shenlogfiles'+d.id+'\')">' +
                                '<span class="layui-hide shenlogfiles'+d.id+'">'+JSON.stringify(d.filesarr)+'</span>' +
                                '<i class="layui-icon layui-icon-link"></i>' +
                                '</span>';
                        }
                        return '';
                    }}
                ]]
                , done: function (res) {
                    soulTable.render(this);
                }
            });
        }

        if(data.talk.length > 0){
            $('#talkDiv').removeClass('layui-hide');
            table.render({
                elem: "#datalist_talk",data:data.talk, toolbar: '#toolbarDemo_talk', page: false
                ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                , cols: [[
                    {type:'numbers',title:'序号',fixed:'left'}
                    ,{field: 'uid_name', title: '评论人'}
                    ,{field: 'domer_name', title: '评论给'}
                    ,{field: 'explain', title: '评论内容'}
                    ,{field: 'created_at', title: '评论时间'}
                    ,{field:'',title:'附件',templet: function(d){
                            if(d.filesarr.length > 0){
                                return '<span class="colorlan" onclick="openTabFilePage(\'talk'+d.id+'\')">' +
                                    '<span class="layui-hide talk'+d.id+'">'+JSON.stringify(d.filesarr)+'</span>' +
                                    '<i class="layui-icon layui-icon-link"></i>' +
                                    '</span>';
                            }
                            return '';
                        }}
                    ,{fixed: 'right', title:'操作', toolbar: '#toolbarDemo_shenlog_opts',align:'center',width:200}
                ]]
                , done: function (res) {
                    soulTable.render(this);
                }
            });
        }
    });




    //按钮
    if(data.bill.but_edit){
        $("#flow_but_edit").removeClass('layui-hide').click(function () {
            var billyushen = data.bill.but_edit_yushen;
            openParentPageEdit('/page/'+data.bill.modenum+'/flow_edit.php?close=1&billyushen='+billyushen+'&isturn=1&id='+data.bill.mid)
            layer_close();
        });
    }
    if(data.bill.but_agree){
        $("#flow_but_agree").removeClass('layui-hide').click(function () {
            openPage('../public_flow/flow_opt_agree.php?id='+data.bill.id+'&isqian='+data.isqian+'&isnext='+data.isnext, '770px', '490px')
        });
    }
    // if(data.bill.but_agreeno){
    //     $("#flow_but_agreeno").removeClass('layui-hide').click(function () {
    //         openPage('../public_flow/flow_opt_agreeno.php?id='+data.bill.id, '770px', '490px')
    //     });
    // }
    if(data.bill.but_tui){
        $("#flow_but_tui").removeClass('layui-hide').click(function () {
            openPage('../public_flow/flow_opt_tui.php?id='+data.bill.id+'&isqian='+data.isqian+'&isnext='+data.isnext, '770px', '490px')
        });
    }

    var dropData = [];
    if(data.bill.but_agreeno){
        dropData.push({title: '不同意',id: 2});
    }
    if(data.bill.but_add){
        dropData.push({title: '加签',id: 4});
    }
    if(data.bill.but_zhuan){
        dropData.push({title: '转签',id: 5});
    }
    if(data.bill.but_out){
        dropData.push({title: '退出审核',id: 6});
    }
    if(data.bill.isturn == 1){
        if(data.bill.status == 0 || data.bill.status == 1 || data.bill.status == 2){
            dropData.push({title: '分享',id: 70});
            dropData.push({title: '评论',id: 80});
        }
    }
    dropData.push({title: '导出',id: 100});
    dropData.push({title: '打印',id: 101});

    layui.use(['dropdown'], function() {
        var dropdown = layui.dropdown;
        dropdown.render({
            elem: '.opt'
            ,data: dropData
            ,click: function(obj){
                if(obj.id == 2){
                    openPage('../public_flow/flow_opt_agreeno.php?id='+data.bill.id+'&isqian='+data.isqian, '770px', '490px');
                }else if(obj.id == 4){
                    openPage('../public_flow/flow_opt_add.php?id='+data.bill.id+'&isqian='+data.isqian, '770px', '490px');
                }else if(obj.id == 5){
                    openPage('../public_flow/flow_opt_zhuan.php?id='+data.bill.id+'&isqian='+data.isqian, '770px', '490px');
                }else if(obj.id == 6){
                    openPage('../public_flow/flow_opt_out.php?id='+data.bill.id, '770px', '490px');
                }else if(obj.id == 70){
                    openPage('../public_flow/flow_opt_share.php?id='+data.bill.id, '770px', '490px');
                }else if(obj.id == 80){
                    openPage('../public_flow/flow_opt_talk.php?id='+data.bill.id, '770px', '490px');
                }else if(obj.id == 100){
                    export_word()
                }else if(obj.id == 101){
                    print_area()
                }
            }
        });
    });
}


function openTabFilePage(classname) {
    openPage('../public/tanfilepage.php?classname='+classname, '900px', '450px');
}


function get_flow_line(list) {
    var linWid = (list.length*170+20);
    var str = '<div class="linebox" style="width: '+linWid+'px;">';
    for(var i=0;i<list.length;i++){
        // if(list[i].state == 0){
        //     str += '<div class="flow-line-box-no">'+list[i].name+'</div>';
        // }
        // if(list[i].state == 1){
        //     str += '<div class="flow-line-box-wait"><img src="../../static/admin/images/flow_line_wait.png">'+list[i].name+'</div>';
        // }
        // if(list[i].state == 2){
        //     str += '<div class="flow-line-box">'+list[i].name+'</div>';
        // }


        if(i > 0){
            str += '<div class="xian xian'+list[i].state+'"></div>';
        }

        if(list[i].state == 0){
            str += '<div class="li">';
            str += '<img src="../../static/admin/images/line_wait.png">';
            str += '<div class="bitext">'+list[i].name+'</div>';
            str += '</div>';
        }
        if(list[i].state == 1){
            str += '<div class="li">';
            str += '<img src="../../static/admin/images/line_curt.png">';
            str += '<div class="bitext">'+list[i].name+'</div>';
            str += '</div>';
        }
        if(list[i].state == 2){
            str += '<div class="li">';
            str += '<img src="../../static/admin/images/line_succ.png">';
            str += '<div class="bitext">'+list[i].name+'</div>';
            str += '</div>';
        }
    }
    str += '</div>';
    setTimeout(function () {
        var flowLineWid = document.getElementById('flowLine').offsetWidth;
        if(linWid > flowLineWid){
            $("#flowLine").css('overflow-x', 'scroll');
        }
    },100);
    return str;
}

function showpage_dropopt() {
    layui.use(['dropdown'], function() {
        var dropdown = layui.dropdown;
        dropdown.render({
            elem: '.opt'
            ,data: [
                {title: '导出',id: 100},
                {title: '打印',id: 101}
            ]
            ,click: function(obj){
                if(obj.id == 100){
                    export_word()
                }else if(obj.id == 101){
                    print_area()
                }
            }
        });
    });
}


function export_word() {
    let exprt_word_name = $(".title_name").html();
    if(exprt_word_name === undefined || exprt_word_name === ''){
        exprt_word_name = '详情';
    }


    let PageContent = '';
    $('.tablenes').each(function () {
        PageContent += '<div class="table-box tablenes">'+$(this).html()+'</div>';
    });

    var areaTits = $("#flow_show_info .fshow_modename").text();
    let export_str = '';
    export_str += '<div id="exportword_content">';
    export_str += '<div style="text-align: center;font-size: 14pt;margin-bottom:10px">'+areaTits+'</div>';
    export_str += '<div id="xiangqingPage"><div id="xiangqingBox" style="padding:unset!important;">'+PageContent+'</div></div>';
    export_str += '</div>';

    layer.open({
        title: '导出 Word'
        ,content: export_str
        ,area: ['80%', '80%']
        ,btn: ['导出Word','取消']
        ,yes: function(index){
            setTimeout(function () {
                $("#exportword_content").wordExport(exprt_word_name);
                layer.close(index);
            },500);
        }
    });

    //去掉附件的下载查看按钮  重新设置 附件标题宽度
    $("#exportword_content i.cha").remove();
    $("#exportword_content i.xia").remove();
    $("#exportword_content .filedivv .filebb .titss").css({'width':'calc(100% - 40px)'});

    //去掉明细列表的导出和列设置按钮 去掉列排序按钮  去掉明细标题加粗
    $("#exportword_content .layui-table-tool-self").remove();
    $("#exportword_content .layui-table-sort").remove();
    $("#exportword_content .table-box .layui-table-tool-temp").attr('style','font-weight:unset!important;');

    //标题栏 去掉加粗
    $("#exportword_content .table-box .title").attr('style','font-weight:unset!important;border:1pt solid #000;border-bottom:none;padding-left:1pt');

    //明细列表  去掉横向纵项滚动条   去掉左侧固定栏   表头放入下方tbody
    $("#exportword_content .layui-table-body").attr('style','height:unset!important;max-height:unset!important');
    $("#exportword_content .layui-table-cell").attr('style','width:auto!important;white-space:unset!important;overflow:unset!important;text-overflow:unset!important;height:auto!important;line-height:unset!important');
    $("#exportword_content .layui-table-fixed-l").remove();
    $("#exportword_content .layui-table-box").each(function () {
        var theadStr = $(this).children('.layui-table-header').children('table').children('thead').html();
        $(this).children('.layui-table-body').children('table').prepend(theadStr);
        $(this).children('.layui-table-body').children('table').attr('style','width:calc(100% - 1px)')
        $(this).children('.layui-table-header').remove();
    });


    $("#exportword_content .table-box table").css({'border-collapse':'collapse','collaps':'0'});
    $("#exportword_content .table-box table th").css({'border':'1pt solid #000'});
    $("#exportword_content .table-box table td").css({'border':'1pt solid #000'});
}
function print_area() {
    let PageContent = '';
    $('.tablenes').each(function () {
        PageContent += '<div class="table-box tablenes">'+$(this).html()+'</div>';
    });

    var areaTits = $("#flow_show_info .fshow_modename").text();
    var zwusername = $("#zwusername" , top.parent.document).text();
    var areatime = getCurtime();

    let export_str = '';
    export_str += '<div id="exportword_content">';
    export_str += '<div style="text-align: center;font-size: 14pt;margin-bottom:10px">'+areaTits+'</div>';
    export_str += '<div style="text-align: right;font-size: 9pt;padding-right: 24px">打印'+areatime+'  '+zwusername+'</div>';
    export_str += '<div id="xiangqingPage"><div id="xiangqingBox" style="padding:unset!important;">'+PageContent+'</div></div>';
    export_str += '</div>';

    layer.open({
        title: '打印'
        ,content: export_str
        ,area: ['80%', '80%']
        ,btn: ['打印','取消']
        ,yes: function(index){
            $(".delbankuai").remove();
            $(".delbanlist").remove();
            $("#exportword_content").printArea();
            layer.close(index);
        }
    });


    $("#exportword_content .layui-table td, #exportword_content .layui-table th").attr('style','font-size:12px!important;padding:0 15px!important;border-color:#333');

    //去掉附件的下载查看按钮  重新设置 附件标题宽度
    $("#exportword_content i.cha").remove();
    $("#exportword_content i.xia").remove();
    $("#exportword_content .filedivv .filebb .titss").css({'width':'calc(100% - 40px)'});

    //去掉明细列表的导出和列设置按钮 去掉列排序按钮  去掉明细标题加粗
    $("#exportword_content .layui-table-tool-self").remove();
    $("#exportword_content .layui-table-sort").remove();
    $("#exportword_content .table-box .layui-table-tool-temp").attr('style','font-weight:unset!important;font-size:12px!important;padding-right:unset');
    $("#exportword_content .table-box .layui-table-tool").attr('style','border:1px solid #333!important;');

    //标题栏 去掉加粗
    $("#exportword_content .table-box .title").attr('style','font-size:12px!important;font-weight:unset!important;border-color:#333;');

    //明细列表  去掉横向纵项滚动条   去掉左侧固定栏   表头放入下方tbody
    $("#exportword_content .layui-table-body").attr('style','height:unset!important;max-height:unset!important;border:1px solid #333!important;');
    $("#exportword_content .layui-table-body .layui-none div").attr('style','border-bottom:1px solid #333!important;');
    $("#exportword_content .layui-table-cell").attr('style','width:auto!important;white-space:unset!important;overflow:unset!important;text-overflow:unset!important;height:auto!important;line-height:unset!important;font-size:12px!important;padding:0');
    $("#exportword_content .layui-table-cell span").attr('style','font-size:12px!important;');
    $("#exportword_content .layui-table-fixed-l").remove();
    $("#exportword_content .layui-table-box").each(function () {
        var theadStr = $(this).children('.layui-table-header').children('table').children('thead').html();
        $(this).children('.layui-table-body').children('table').prepend(theadStr);
        $(this).children('.layui-table-body').children('table').attr('style','width:calc(100% - 1px)')
        $(this).children('.layui-table-header').remove();
    });


    $("#exportword_content .table-box .title").append('<span class="delbankuai" title="取消该区域打印" style="font-size: 14px;color:red;float: right;margin-right:10px;padding:0 5px;cursor: pointer;">x</span>')
    $("#exportword_content .table-box .layui-table-tool-temp").append('<span class="delbanlist" title="取消该区域打印" style="font-size: 14px;color:red;cursor: pointer;position:absolute;right:10px;padding: 0 5px;">x</span>')

    $(".delbankuai").click(function (e) {
        $(this).parents('.tablenes').remove();
    });
    $(".delbanlist").click(function (e) {
        $(this).parents('.tablenes').remove();
    });
}


function print_area2222222() {
    let PageContent = '';
    $('.tablenes').each(function () {
        PageContent += '<div class="table-box tablenes">'+$(this).html()+'</div>';
    });

    var areaTits = $("#flow_show_info .fshow_modename").text();
    let export_str = '';
    export_str += '<div id="exportword_content">';
    export_str += '<div style="text-align: center;font-size: 14pt;margin-bottom:10px">'+areaTits+'</div>';
    export_str += '<div id="xiangqingPage"><div id="xiangqingBox" style="padding:unset!important;">'+PageContent+'</div></div>';
    export_str += '</div>';

    layer.open({
        title: '打印'
        ,content: export_str
        ,area: ['80%', '80%']
        ,btn: ['打印','取消']
        ,yes: function(index){
            $("#exportword_content").printArea();
            layer.close(index);
        }
    });
    $("#exportword_content i.cha").remove();
    $("#exportword_content i.xia").remove();
    $("#exportword_content .layui-table-tool-self").remove();
    $("#exportword_content .filedivv .filebb .titss").css({'width':'calc(100% - 40px)'});
    $("#exportword_content .layui-table-sort").remove();


    $("#exportword_content .table-box .layui-table-tool").attr('style','padding:unset!important');
    $("#exportword_content .table-box .layui-table-tool-temp").attr('style','font-weight:unset!important;padding-left:10px')
        .css({'border':'1px solid #eee','border-bottom':'none','font-weight':'300!important;'});
    $("#exportword_content .table-box .title").attr('style','font-weight:unset!important')
        .css({'border':'1px solid #eee','border-bottom':'none','font-weight':'300!important'});

    $("#exportword_content .layui-table-body").attr('style','height:unset!important;max-height:unset!important');
    $("#exportword_content th").css({'border':'1pt solid #eee'});
    $("#exportword_content td").css({'border':'1pt solid #eee'});


    $("#exportword_content .layui-table-cell").attr('style','width:auto!important;white-space:unset!important;overflow:unset!important;text-overflow:unset!important;height:auto!important;line-height:unset!important');
    $("#exportword_content .layui-table-fixed-l").remove();
    $("#exportword_content .layui-table-box").each(function () {
        var theadStr = $(this).children('.layui-table-header').children('table').children('thead').html();
        $(this).children('.layui-table-body').children('table').prepend(theadStr);
        $(this).children('.layui-table-body').children('table').attr('style','width:calc(100% - 1px)')
        $(this).children('.layui-table-header').remove();
    });

}
function export_word2() {
    let exprt_word_name = $(".title_name").html();
    if(exprt_word_name === undefined || exprt_word_name === ''){
        exprt_word_name = '详情';
    }

    let PageContent = $(".export-print").html();
    let export_str = '<div id="exportword_content">'+PageContent+'</div>';
    layer.open({
        title: '导出 Word'
        ,content: export_str
        ,area: ['80%', '80%']
        ,btn: ['导出Word','取消']
        ,yes: function(index){
            setTimeout(function () {
                $("#exportword_content table>thead>tr>th>span.icon").remove();
                $('#exportword_content table').after('<br/><br/><br/><br/>')
                $("#exportword_content").wordExport(exprt_word_name);
                layer.close(index);
            },500);
        }
    });
    $("#exportword_content #show_button").remove();
    $("#exportword_content .expoerword_not").remove();
    $("#exportword_content table>thead>tr>th>span.icon").html('<span class="del_word_nav" onclick="del_word_nav(this)">x</span>')
    $("#exportword_content table>thead>tr>th").attr('onclick','');
    $("#exportword_content table").css({'width':'100%','border-collapse':'collapse','border':'none','font-size':'14px'});

    $("#exportword_content .one_tbody tr td:first-child").css('width','20%');
    $("#exportword_content .one_tbody tr td:nth-child(3)").css('width','20%');
    $("#exportword_content .one_tbody tr td:nth-child(2)").css('width','30%');
    $("#exportword_content .one_tbody tr td:nth-child(4)").css('width','30%');

    $("#exportword_content .title").css({'border':'1px solid #000','border-bottom':'0'});
    $("#exportword_content .title-list").css({'border':'1px solid #000','border-bottom':'0'});
    $("#exportword_content .title-file").css({'border':'1px solid #000','border-bottom':'0'});
    $("#exportword_content .table-box table th").css({'border':'1px solid #000'});
    $("#exportword_content .table-box table td").css({'border':'1px solid #000'});
}
function print_area2() {
    let PageContent = $(".export-print").html();
    let export_str = '<div id="exportword_content">'+PageContent+'</div>';
    layer.open({
        title: '打印'
        ,content: export_str
        ,area: ['80%', '80%']
        ,btn: ['打印','取消']
        ,yes: function(index){
            setTimeout(function () {
                $("#exportword_content table>thead>tr>th>span.icon").remove();
                $('#exportword_content table').after('<br/><br/><br/><br/>')
                $("#exportword_content").printArea();
                layer.close(index);
            },500);
        }
    });
    $("#exportword_content #show_button").remove();
    $("#exportword_content .expoerword_not").remove();
    $("#exportword_content table>thead>tr>th>span.icon").html('<span class="del_word_nav" onclick="del_word_nav(this)">x</span>')
    $("#exportword_content table>thead>tr>th").attr('onclick','');
    $("#exportword_content table").css({'width':'100%','border-collapse':'collapse','border':'none','font-size':'14px'});

    $("#exportword_content .one_tbody tr td:first-child").css('width','20%');
    $("#exportword_content .one_tbody tr td:nth-child(3)").css('width','20%');
    $("#exportword_content .one_tbody tr td:nth-child(2)").css('width','30%');
    $("#exportword_content .one_tbody tr td:nth-child(4)").css('width','30%');

    $("#exportword_content .title").css({'border':'1px solid #000','border-bottom':'0'});
    $("#exportword_content .title-list").css({'border':'1px solid #000','border-bottom':'0'});
    $("#exportword_content .title-file").css({'border':'1px solid #000','border-bottom':'0'});
    $("#exportword_content .table-box table th").css({'border':'1px solid #000'});
    $("#exportword_content .table-box table td").css({'border':'1px solid #000'});
}
function del_word_nav(obj) {
    $(obj).parents('table').remove();
}
